
#include <BRender>
#include "AxisShape.h"

AxisShape::AxisShape()
{
	_xtop.set(10, 0, 0);
	_ytop.set(0, 10, 0);
	_ztop.set(0, 0, 10);
}
AxisShape::~AxisShape()
{

}

BBox AxisShape::refresh()
{
	BSpace space;
	space.expand(_xtop);
	space.expand(_ytop);
	space.expand(_ztop);
	return space;
}
void AxisShape::render(BRender& render)
{
	render.setLighting(false);
	render.setLineWidth(3);

	render.setColor(255, 0, 0);
	render.drawLine(BVector(), _xtop);

	render.setColor(0, 255, 0);
	render.drawLine(BVector(), _ytop);

	render.setColor(0, 0, 255);
	render.drawLine(BVector(), _ztop);

	BQuater xrotate(BVector(1, 0, 0), _euler.x());
	BQuater yrotate(BVector(0, 1, 0), _euler.y());
	BQuater zrotate(BVector(0, 0, 1), _euler.z());
	BVector point(10, 0, 0);
	BMatrix matrix;
	matrix.setRotate(xrotate * yrotate * zrotate);
	point *= matrix;
	render.setColor(255, 255, 255);
	render.drawLine(BVector(), point);
}
